﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using s2b.ControleDesenvolvimentoProjetos.Util.Auxiliar;
using s2b.ControleDesenvolvimentoProjetos.Dados.OBJ;
using System.Data.SqlClient;
using System.Drawing;

namespace s2b.ControleDesenvolvimentoProjetos.UserControls
{
    public partial class WUCFeedbackNegativo : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MontaTable();
        }
        public void MontaTable()
        {
            

            SqlDataReader executa = Auxiliar.RetornaRegistros(@"SELECT     T.ID_STATUS, T.ID_TAREFA, T.NOME_TAREFA, F.POSITIVO, FC.NOME_FUNC, FC.SOBRE_NOME, P.NOME_PROJETO
FROM         FEEDBACK AS F INNER JOIN
                      TAREFAS AS T ON T.ID_TAREFA = F.ID_TAREFA INNER JOIN
                      FUNCIONARIO AS FC ON FC.ID_FUNC = F.ID_FUNC INNER JOIN
                      PROJETO AS P ON P.ID_PROJETO = T.ID_PROJETO ORDER BY F.ID_FEEDBACK DESC", Feedback.Tabela);

            if (executa != null)
            {
                while (executa.Read())
                {
                    Table tblFeedbacks = new Table();

                    Table tblFeedback = new Table();
                    TableRow rowFeedbackProjeto = new TableRow();
                    TableCell cellLblFeedbackProjeto = new TableCell();
                    TableCell cellConteudoFeedbackProjeto = new TableCell();
                    Label lblProjeto = new Label();
                    lblProjeto.Text = "Projeto";
                    Label lblConteudoProjeto = new Label();
                    lblConteudoProjeto.Text = executa["NOME_PROJETO"].ToString();
                    cellLblFeedbackProjeto.Controls.Add(lblProjeto);
                    cellConteudoFeedbackProjeto.Controls.Add(lblConteudoProjeto);
                    rowFeedbackProjeto.Controls.Add(cellLblFeedbackProjeto);
                    rowFeedbackProjeto.Controls.Add(cellConteudoFeedbackProjeto);
                    tblFeedbacks.Controls.Add(rowFeedbackProjeto);

                 
                    TableRow rowFeedbackTarefa = new TableRow();
                    TableCell cellLblFeedbackTarefa = new TableCell();
                    TableCell cellConteudoFeedbackTarefa = new TableCell();
                    Label lblTarefa = new Label();
                    lblTarefa.Text = "Tarefa";
                    Label lblConteudoTarefa = new Label();
                    lblConteudoTarefa.Text = executa["NOME_TAREFA"].ToString();
                    cellLblFeedbackTarefa.Controls.Add(lblTarefa);
                    cellConteudoFeedbackTarefa.Controls.Add(lblConteudoTarefa);
                    rowFeedbackTarefa.Controls.Add(cellLblFeedbackTarefa);
                    rowFeedbackTarefa.Controls.Add(cellConteudoFeedbackTarefa);
                    tblFeedbacks.Controls.Add(rowFeedbackTarefa);



                    TableRow rowFeedbackResponsavel = new TableRow();
                    TableCell cellLblFeedbackResponsavel = new TableCell();
                    TableCell cellConteudoFeedbackResponsavel = new TableCell();
                    Label lblResponsavel = new Label();
                    lblResponsavel.Text = "Responsavel";
                    Label lblConteudoResponsavel = new Label();
                    string func = String.Format("{0} {1}", executa["NOME_FUNC"].ToString(), executa["SOBRE_NOME"].ToString());
                    lblConteudoResponsavel.Text = func;
                    cellLblFeedbackResponsavel.Controls.Add(lblResponsavel);
                    cellConteudoFeedbackResponsavel.Controls.Add(lblConteudoResponsavel);
                    rowFeedbackResponsavel.Controls.Add(cellLblFeedbackResponsavel);
                    rowFeedbackResponsavel.Controls.Add(cellConteudoFeedbackResponsavel);
                    tblFeedbacks.Controls.Add(rowFeedbackResponsavel);


                    TableRow rowFeedbackPositivo = new TableRow();
                    TableCell cellLblFeedbackPositivo = new TableCell();

                    TableCell cellConteudoFeedbackPositivo = new TableCell();

                    Label lblPositivo = new Label();
                    lblPositivo.Text = "Feedback";
                    Label lblConteudoPositivo = new Label();
                    lblConteudoPositivo.Text = executa["POSITIVO"].ToString();
                    cellLblFeedbackPositivo.Controls.Add(lblPositivo);
                    cellConteudoFeedbackPositivo.Controls.Add(lblConteudoPositivo);
                    rowFeedbackPositivo.Controls.Add(cellLblFeedbackPositivo);
                    rowFeedbackPositivo.Controls.Add(cellConteudoFeedbackPositivo);
                    tblFeedbacks.Controls.Add(rowFeedbackPositivo);





                    TableRow rowFeedbackBotao = new TableRow();
                    TableCell cellFeedbackBotao = new TableCell();
                                   

                    ImageButton btnAjudar = new ImageButton();
                    string url = String.Format("WFTarefaIndividual.aspx?ID_TAREFA={0}", executa[Tarefa.Id].ToString());
                    btnAjudar.OnClientClick = String.Format("javascript:window.open('{0}','_blank');", url);
                    btnAjudar.ImageUrl = "/Util/Imagens/help.png";
                    cellFeedbackBotao.Controls.Add(btnAjudar);

                    rowFeedbackBotao.Controls.Add(cellFeedbackBotao);
           
                    tblFeedbacks.Controls.Add(rowFeedbackBotao);







                    //TableRow row = new TableRow();
                    //TableCell cell = new TableCell();
                    //cell.Controls.Add(tblFeedback);
                    //tblFeedbacks.Controls.Add(row);
                    tblFeedbacks.BorderColor = Color.White;
                    tblFeedbacks.BorderStyle = BorderStyle.Solid;
                    tblFeedbacks.BorderWidth = 5;
                    if (lblConteudoPositivo.Text.ToUpper().Equals("POSITIVO"))
                    {
                        tblFeedbacks.BackColor = Color.Green;
                    }
                    else {
                        if (lblConteudoPositivo.Text.ToUpper().Equals("NEGATIVO")) {
                            tblFeedbacks.BackColor = Color.Red;
                        }
                    }
              
                 
                    Panel1.Controls.Add(tblFeedbacks);
  
                   







                }
            }
          //  Table1 = tblFeedbacks;
           
        }
    }
}